package com.yonyou.pmclouds.altercategory.process;

import com.yonyou.pmclouds.altercategory.entity.AlterCategoryVO;
import com.yonyou.pmclouds.altercategory.mapper.AlterCategoryMapper;
import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;

public class AlterCategoryUpdateCheckProcessor implements SingleProcessor<AlterCategoryVO> {

    private AlterCategoryMapper mapper;

    public AlterCategoryUpdateCheckProcessor(AlterCategoryMapper mapper) {
        this.mapper = mapper;
    }
    @Override
    public void process(AlterCategoryVO vo, AlterCategoryVO orig) throws BusinessException {
        if(vo == null || orig == null){
            return;
        }else if(vo.getSname().equals(orig.getSname())){
            return;
        }else {
            if(mapper.countName(vo.getPkTenant(), vo.getSname()) > 0){
                throw new BusinessException("类别名称重复！");
            }
        }
    }
}
